home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / System 7.0 Samples / INIT - CDEV / Common.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-18  |  3.4 KB  |  90 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Macintosh Developer Technical Support
  4. #
  5. #    Sample Control Panel Device and INIT Combination
  6. #
  7. #    Program:    INIT - CDEV
  8. #    File:        Common.h    -    C Header for CDEV.c and INIT.c
  9. #
  10. #    Copyright © 1990 Apple Computer, Inc.
  11. #    All rights reserved.
  12. #
  13. ------------------------------------------------------------------------------*/
  14.  
  15. #include <Types.h>
  16. #include <Errors.h>
  17. #include <Events.h>
  18. #include <Folders.h>
  19. #include <Gestalt.h>
  20. #include <PLStringFuncs.h>
  21. #include <PPCToolBox.h>
  22. #include <Script.h>
  23.  
  24.  
  25. /*    Information about our preferences file. We keep the name, file type, and
  26.     creator type stored here. If we ever change the creator type, we'd have
  27.     to modify kCreator. */
  28.  
  29. #define kPrefsFileName "\pBackground Beeper Prefs"
  30. #define kCreator 'INCD'
  31. #define kDocKind 'PREF'
  32.  
  33.  
  34. /*    Common constants. kGetCommonGlobalsPtr is the message number we send to the
  35.     INIT when we want it to return a pointer to its globals. If we wanted to ask
  36.     it other things, we could define more message numbers. kBufferSize is the
  37.     size of the buffer we use for messaging. Currently, we only return a pointer
  38.     as data, so 256 is way overkill. However, if we define other messages that
  39.     could result in the transfer of more data, 256 bytes could some in handy. */
  40.     
  41. enum {kGetCommonGlobalsPtr = 1000};
  42. enum {kBufferSize = 256};
  43.  
  44.  
  45. /*    Format of the public globals. The INIT uses these two fields when
  46.     determining when to beep. When the user closes the CDEV, the two values
  47.     are updated in memory, and are written out to the preferences file. */
  48.  
  49. typedef struct {
  50.     short            timesToBeep;
  51.     long            beepInterval;
  52. } CommonGlobalsRec, *CommonGlobalsPtr;
  53.  
  54.  
  55. /*    This struct is used for our PPC communications. It consists of five parts.
  56.     The first field is a parameter block large enough for any PPC call. We
  57.     use that parameter block for all of our calls. We only make one call at 
  58.     a time, so this is OK. The next three fields are used as extended
  59.     information for the PPC parameter block. The parameter block needs to 
  60.     have some pointers to additional information stored in it. To keep
  61.     everything together, we keep that extra information along with the
  62.     parameter block. Finally, we have the buffer that's used for transferring
  63.     information in PPCRead and PPCWrite calls. This is also kept with the
  64.     parameter block so that when we get to the Read/Write portion of our
  65.     show, we have a handy buffer at a known offset from the parameter block. */
  66.     
  67. typedef struct {
  68.     PPCParamBlockRec    pb;
  69.     PPCPortRec            portName;
  70.     LocationNameRec        locationName;
  71.     Str255                userName;
  72.     char                buffer[kBufferSize];
  73. } SessionRecord, *SessionPtr;
  74.  
  75.  
  76. /*    When the INIT receives a message number, it has to decide what information
  77.     to return. This information is stored in the buffer in the SessionRecord
  78.     and then we make a PPCWrite call. Depending on the message number, we
  79.     might have to return different kinds of information. To make this
  80.     easier, we define different structs to overlay on top of the buffer.
  81.     Since we only have one message number (get the pointer to the global
  82.     variables), we have only one struct overlay, which is below. However,
  83.     we could easily add more. We could even merge them all together into a
  84.     union, and define our buffer to be the size of the union. */
  85.  
  86. typedef struct {
  87.     CommonGlobalsPtr    commonGlobalsAddress;        // <- return the address of our globals here
  88. } GetCommonGlobalsRecord, *GetCommonGlobalsPtr;
  89.  
  90.